<!DOCTYPE html>
<html>

	<head lang="en">
		<meta charset="UTF-8">
		<title>注册</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
		<meta name="format-detection" content="telephone=no">
		<meta name="renderer" content="webkit">
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<link href="{{asset('Home/css')}}/dlstyle.css" rel="stylesheet" type="text/css">
		<link rel="stylesheet" href="{{asset('Home/css')}}/amazeui.min.css" />
		<script src="{{asset('Home/js')}}/jquery.min.js"></script>
		<script src="{{asset('Home/js')}}/amazeui.min.js"></script>

	</head>

	<body>

		<div class="login-boxtitle">
			<a href="/"><img alt="" src="{{asset('Home/images')}}/qqa.jpg" style="height:55px;margin:20px" /></a>
			<!-- <div class="reglogo-title">欢迎注册</div> -->
			<div class="have-account">
				已有账号？
				<a href="/finallogin" style="font-size:20px; color:black">请登录</a>
			</div>
		</div>

		<div class="res-banner">
			<!-- 右侧图片 -->
			<div class="res-main">
				<div class="login-banner-bg"><span></span></div>
				<!-- 左侧图片 -->
				<div class="login-box">
					<div class="am-tab-panel">
						<form method="post" action="javascript:;">
							<div class="user-name">
								<label for="username"><i class="am-icon-user"></i></label>
								<input type="text" name="uname" id="username" placeholder="输入用户名">
								<span id="name0" style="display:none;color:#F3726D;font-size:13px">用户名已存在</span>
								<span id="name1" style="display:none;color:#76EE00;font-size:14px">用户名可用</span>
								<span id="name2" style="display:none;color:#F3726D;font-size:13px">用户名格式有误,必须由6-16位数字,字母组成</span>
								<span id="name3" style="display:none;color:#F3726D;font-size:13px">用户名不能为空</span>

							</div>
							<div class="user-pass">
								<label for="password"><i class="am-icon-lock"></i></label>
								<input type="password" name="upass" id="password" placeholder="设置密码">
								<span id="pass1" style="display:none;color:#76EE00;font-size:14px">密码可以使用</span>
								<span id="pass2" style="display:none;color:#F3726D;font-size:14px">密码格式有误,必须包含数字,字母和特殊符号</span>
								<span id="pass3" style="display:none;color:#F3726D;font-size:13px">密码不能为空</span>
								
							</div>
							<div class="user-pass">
								<label for="passwordRepeat"><i class="am-icon-lock"></i></label>
								<input type="password" name="repass" id="passwordRepeat" placeholder="确认密码">
								<span id="repass0" style="display:none;color:#F3726D;font-size:13px">请填写确认密码</span>
								<span id="repass1" style="display:none;color:#F3726D;font-size:13px">两次输入密码不一致</span>
								<span id="repass2" style="display:none;color:#76EE00;font-size:13px">密码一致</span>
							</div>
							<div class="user-email">
								<label for="email"><i class="am-icon-envelope"></i></label>
								<input type="text" name="email" id="email" placeholder="输入邮箱">
								<span id="email0" style="display:none;color:#F3726D;font-size:14px">邮箱已被注册</span>
								<span id="email1" style="display:none;color:#76EE00;font-size:14px">邮箱格式正确</span>
								<span id="email2" style="display:none;color:#F3726D;font-size:14px">邮箱格式有误</span>
								<span id="email3" style="display:none;color:#F3726D;font-size:13px">邮箱不能为空</span>
							</div>

							<div class="user-phone">
								<label for="phone"><i class="am-icon-mobile-phone am-icon-md"></i></label>
								<input type="tel" name="uphone" id="phone" placeholder="请输入手机号">
								<span id="phone0" style="display:none;color:#F3726D;font-size:14px">该手机号已被注册</span>
								<span id="phone1" style="display:none;color:#76EE00;font-size:14px">手机格式正确</span>
								<span id="phone2" style="display:none;color:#F3726D;font-size:14px">手机号格式有误,必须由11位数字组成</span>
								<span id="phone3" style="display:none;color:#F3726D;font-size:13px">手机号不能为空</span>
							</div>
							@if ($registerCode == 1) 
							<div class="verification">
								<label for="code"><i class="am-icon-code-fork"></i></label>
								<input type="tel" name="code" id="code" placeholder="请输入验证码">
								<input type="button" id="dyMobileButton" value="获取验证码" onclick="sendemail()" /> 
								<span id="code0" style="display:none;color:#F3726D;font-size:14px">验证码为空</span>
								<span id="code1" style="display:none;color:#76EE00;font-size:14px">验证码正确</span>
								<span id="code2" style="display:none;color:#F3726D;font-size:14px">验证码错误</span>
								<span id="code3" style="display:none;color:#F3726D;font-size:14px">验证码格式有误</span>
								
									
							</div>
							@else
							<div class="verification">
								<label for="code"><i class="am-icon-code-fork"></i></label>
								<input type="tel" name="code" id="code" placeholder="请输入验证码" style="width:165px">
								<img src="{{url('/makecode')}}" alt="" id="codeimage" onclick="this.src='{{url('/makecode')}}?'+Math.random();" style="">

							</div>
							@endif
						</form>
								
						<div class="am-cf">
							<!-- <input type="submit" name="" value="注册" class="am-btn am-btn-primary am-btn-sm am-fl"> -->
							<a href="javascript:;" class="am-btn am-btn-primary am-btn-sm am-fl am-register" style="background-color:#F3726D;border-color:#F3726D">注册</a>
						</div>

					</div>

					<script>
						// 判断用户名格式
						   //判断用户名失去焦点时
					    $('input[name="uname"]').blur(function () {
					        
					        //判断用户名是否为空，为空则显示不能为空
					        if ($('input[name="uname"]').val().length == 0) {
					          			$("#name2").css("display","none");
										$("#name1").css("display","none");
										$("#name3").css("display","block");
										$("input[name='uname']").on('focus',function() {
											$("#name2").css("display","none");
											$("#name1").css("display","none");
											$("#name3").css("display","none");
										});
										return false;
					     
					        }
					       
					        //判断用户输入的数据是否符合正则验证
					        var uname = $('input[name="uname"]').val();
					        var patrn = /^[a-zA-Z0-9]{6,16}$/;
					        var str =  uname.match(patrn);
					        if (str == null ) {
					        			$("#name1").css("display","none");
										$("#name3").css("display","none");
					          			$("#name2").css("display","block");
										$("input[name='uname']").on('focus',function() {
											$("#name2").css("display","none");
											$("#name1").css("display","none");
											$("#name3").css("display","none");
										});
										return false;
											
					        }

					        $.post(
					        	'/user/name',
       							{'_token':'{{csrf_token()}}','name':$("#username").val()},
       								function(data) {
       									if (data == 1 ) {
       										$("#name1").css("display","none");
											$("#name2").css("display","none");		
											$("#name0").css("display","block");
											$("input[name='uname']").on('focus',function() {
												$("#name1").css("display","none");
												$("#name2").css("display","none");
												$("#name0").css("display","none");
											});
										}else if (data==2){

											$("#name2").css("display","none");
											$("#name1").css("display","block");
											$("input[name='uname']").on('focus',function() {
												$("#name2").css("display","none");
											});
										}
       								}
					        	)
					    });
						
						// 判断手机格式
						   //判断手机失去焦点时
					    $('input[name="uphone"]').blur(function () {
					        
					        //判断手机是否为空，为空则显示不能为空
					        if ($('input[name="uphone"]').val().length == 0) {
					          			$("#phone2").css("display","none");
										$("#phone1").css("display","none");
										$("#phone3").css("display","block");
										$("input[name='uphone']").on('focus',function() {
											$("#phone2").css("display","none");
											$("#phone1").css("display","none");
											$("#phone3").css("display","none");
										});
										return false;
					     
					        }
					       
					        //判断用户输入的数据是否符合正则验证
					        var uphone = $('input[name="uphone"]').val();
					        var patrn = /^1\d{10}$/;
					        var str =  uphone.match(patrn);
					        if (str == null ) {
					        			$("#phone1").css("display","none");
										$("#phone3").css("display","none");
					          			$("#phone2").css("display","block");
										$("input[name='uphone']").on('focus',function() {
											$("#phone2").css("display","none");
											$("#phone1").css("display","none");
											$("#phone3").css("display","none");
										});
										return false;					
					        }

					        $.post(
					        	'/user/phone',
       							{'_token':'{{csrf_token()}}','phone':$("#phone").val()},
       								function(data) {
       									if (data == 1 ) {
       										$("#phone1").css("display","none");
											$("#phone2").css("display","none");		
											$("#phone0").css("display","block");
											$("input[name='uphone']").on('focus',function() {
												$("#phone1").css("display","none");
												$("#phone2").css("display","none");
												$("#phone0").css("display","none");
											});
										}else if (data==2){

											$("#phone2").css("display","none");
											$("#phone1").css("display","block");
											$("input[name='uphone']").on('focus',function() {
												$("#phone2").css("display","none");
											});
										}
       								}
					        	)
					    });
						// 按钮接收验证码
						var countdown=60; 
						// var codes = Math.floor(Math.random()*8999+1000);
						function sendemail(){
						    var obj = $("#dyMobileButton");
						    var userPhone = $('input[name="uphone"]').val().trim();
						    var phoneLen = userPhone.length;
							  	if (phoneLen == 11) {
							  		 settime(obj);
							  	}    
						    }
						function settime(obj) { //发送验证码倒计时
						    if (countdown == 0) { 
						        obj.attr('disabled',false); 
						        //obj.removeattr("disabled"); 
						        obj.val("获取验证码");
						        countdown = 5; 
						        return;
						    } else { 
						        obj.attr('disabled',true);
						        obj.val("重新发送(" + countdown + ")");
						        countdown--; 
						    } 
						setTimeout(function() { 
						    settime(obj) }
						    ,1000) 
						}
						// 提交手机以获取验证码
						$('#dyMobileButton').click(function(){
						 	//判断手机是否为空，为空则显示不能为空
					        if ($('input[name="uphone"]').val().length == 0) {
					          			$("#phone2").css("display","none");
										$("#phone1").css("display","none");
										$("#phone3").css("display","block");
										$("input[name='uphone']").on('focus',function() {
											$("#phone2").css("display","none");
											$("#phone1").css("display","none");
											$("#phone3").css("display","none");
										});
										return false;
					        }
						    var phone = $.trim($('#phone').val());
						    // alert('12');
						    $.post("{{url('/docode')}}", 
						      	{'_token':'{{csrf_token()}}',
						      	'phone':phone},
						      	function(res){
						        if ( res == 1 ) {
						          	alert('验证码发送成功');
						        } else if( res == 2 ) {
						        	alert('验证码发送失败');
						        }
						      });
						    });
						// 判断验证码格式
						//判断验证失去焦码点时
					    $('input[name="code"]').blur(function () {
					        //判断验证码是否为空，为空则显示不能为空
					        if ($('input[name="code"]').val().length == 0) {
					          			$("#code2").css("display","none");
										$("#code1").css("display","none");
										$("#code0").css("display","block");
										$("input[name='code']").on('focus',function() {
											$("#code2").css("display","none");
											$("#code1").css("display","none");
											$("#code0").css("display","none");
										});
										return false;
					     
					        }
					        $.post(
					        	'/user/code',
       							{'_token':'{{csrf_token()}}','code':$("#code").val(),
       							'phone':$("#phone").val()
       							},
       								function(data) {
       									if (data == 1 ) {
       										$("#code0").css("display","none");
											$("#code2").css("display","none");		
											$("#code1").css("display","block");
											$("input[name='code']").on('focus',function() {
												$("#code1").css("display","none");
												$("#code2").css("display","none");
												$("#code0").css("display","none");
											});
										}else if (data== 2){
											$("#code1").css("display","none");
											$("#code2").css("display","block");
											$("input[name='code']").on('focus',function() {
												$("#code2").css("display","none");
												$("#code1").css("display","none");
											});
										}
       								}
					        	)
					    });
						// 判断邮箱格式
						$('input[name="email"]').blur(function () {
					        //判断邮箱是否为空，为空则显示不能为空
					        if ($('input[name="email"]').val().length == 0) {
					          			$("#email2").css("display","none");
										$("#email1").css("display","none");
										$("#email3").css("display","block");
										$("input[name='email']").on('focus',function() {
											$("#email2").css("display","none");
											$("#email1").css("display","none");
											$("#email3").css("display","none");
										});
										return false;
					        }
					        //判断用户输入的数据是否符合正则验证
					        var uemail = $('input[name="email"]').val();
					        var patrn = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
					        var str =  uemail.match(patrn);
					        if (str == null ) {
					        			$("#email1").css("display","none");
										$("#email3").css("display","none");
					          			$("#email2").css("display","block");
										$("input[name='email']").on('focus',function() {
											$("#email2").css("display","none");
											$("#email1").css("display","none");
											$("#email3").css("display","none");
										});
										return false;			
					        }
					        $.post(
					        	'/user/email',
       							{'_token':'{{csrf_token()}}','email':$("#email").val()},
       								function(data) {
       									if (data == 1 ) {
       										$("#email1").css("display","none");
											$("#email2").css("display","none");		
											$("#email0").css("display","block");
											$("input[name='email']").on('focus',function() {
												$("#email1").css("display","none");
												$("#email2").css("display","none");
												$("#email0").css("display","none");
											});
										}else if (data==2){

											$("#email2").css("display","none");
											$("#email1").css("display","block");
											$("input[name='email']").on('focus',function() {
												$("#email2").css("display","none");
											});
										}
       								}
					        	)
					    });
						// 判断密码格式
						$('input[name="upass"]').blur(function () {
							$.post(
								'/user/pass',
								{'_token':'{{csrf_token()}}','pass':$("#password").val()},
								function (passdata)
								{
									if ( passdata == 2 && $('input[name="upass"]').val().length>0) {
										$("#passwordRepeat").attr("disabled","disabled"); 
										$('#repass0').css("display","none");
										$('#pass1').css("display","none");
										$('#pass2').css("display","block");
										$("input[name='upass']").on('focus',function() {
											$('#pass2').css("display","none");
											$('#pass1').css("display","none");
										});
									}else if( passdata == 2 && $('input[name="upass"]').val().length == 0 ) {
										$("#passwordRepeat").attr("disabled","disabled"); 
										$('#repass0').css("display","none");
										$('#pass2').css("display","none");
										$('#pass3').css("display","block");
										$('input[name="upass"]').on('focus',function() {
											$('#pass2').css("display","none");
											$('#pass3').css("display","none");
										});
										return false;
									}else if( passdata == 1 ) {
										$("#passwordRepeat").removeAttr("disabled"); 
										$('#pass2').css("display","none");
										$('#pass1').css("display","block");
										$('input[name="upass"]').on('focus',function() {
											$('#pass2').css("display","none");
										});
									}
								});
						});
						// 判断两次密码是否一致
						$('input[name="repass"]').blur(function () {
				       		
				       		if ($('input[name="repass"]').val().length == 0) {

				       				$('#repass2').css("display","none");
				       				$('#repass0').css("display","block");
				       				$('input[name="repass"]').on('focus',function() {
				       					$('#repass1').css("display","none");
				       					$('#repass2').css("display","none");
				       					$('#repass0').css("display","none");
				       			 	});
				       			 	return false;
				       		}
				       		if ( $('input[name="repass"]').val() ==  $('input[name="upass"]').val()) {

				       				$('#repass2').css("display","block");
				       				$('input[name="repass"]').on('focus',function() {
				       					$('#repass2').css("display","none");
				       					$('#repass1').css("display","none");
				       			 	});
				       		}else {
				       				$('#repass2').css("display","none");
				       				$('#repass1').css("display","block");
				       				$('input[name="repass"]').on('focus',function() {
				       					$('#repass1').css("display","none");
				       					$('#repass2').css("display","none");
				       			 	});
				       		}				        
				        });
					//处理注册提交
					$('a.am-register').on( 'click',function () {
						var uname = $('input[name="uname"]').val();
						var upass = $('input[name="upass"]').val();
						var repass = $('input[name="repass"]').val();
						var email = $('input[name="email"]').val();
						var uphone = $('input[name="uphone"]').val();
						var code = $('input[name="code"]').val();
						$.ajax({
						type: 'post',
						url: '{{url("/doregister")}}',
						data: 'name='+uname+'&pass='+upass+'&repass='+repass+'&email='+email+'&phone='+uphone+'&code='+code+'&_token={{csrf_token()}}',
						success: function (data) {
							if(data.status == 1200){

										alert('注册成功');

										location.href = '{{url("/finallogin")}}';
								}else if(data.status == 1501){

										// alert('注册失败,请填写用户名');
										$("#name2").css("display","none");
										$("#name1").css("display","none");
										$("#name3").css("display","block");
										$("input[name='uname']").on('focus',function() {
											$("#name2").css("display","none");
											$("#name1").css("display","none");
											$("#name3").css("display","none");
										});		
								}else if(data.status == 1502){
										// alert('注册失败,请填写密码');
										$('#repass0').css("display","none");
										$('#pass2').css("display","none");
										$('#pass3').css("display","block");
										$('input[name="upass"]').on('focus',function() {
											$('#pass2').css("display","none");
											$('#pass3').css("display","none");
										});	
								}else if(data.status == 15002){

										// alert('注册失败,请填写确认密码');
										$('#repass2').css("display","none");
				       					$('#repass0').css("display","block");
				       					$('input[name="repass"]').on('focus',function() {
				       						$('#repass1').css("display","none");
				       						$('#repass2').css("display","none");
				       						$('#repass0').css("display","none");
				       			 	});		
								}else if(data.status == 1503){
										// alert('注册失败,请填写邮箱');
										$("#email2").css("display","none");
										$("#email1").css("display","none");
										$("#email3").css("display","block");
										$("input[name='email']").on('focus',function() {
											$("#email2").css("display","none");
											$("#email1").css("display","none");
											$("#email3").css("display","none");
										});		
								}else if(data.status == 1504){
										// alert('注册失败,请填写手机号码');
										$("#phone2").css("display","none");
										$("#phone1").css("display","none");
										$("#phone3").css("display","block");
										$("input[name='uphone']").on('focus',function() {
											$("#phone2").css("display","none");
											$("#phone1").css("display","none");
											$("#phone3").css("display","none");
										});		
								}else if(data.status == 1505){
										// alert('注册失败,请填写手机验证码');
										$("#code2").css("display","none");
										$("#code1").css("display","none");
										$("#code0").css("display","block");
										$("input[name='code']").on('focus',function() {
											$("#code2").css("display","none");
											$("#code1").css("display","none");
											$("#code0").css("display","none");
										});		
								}else if(data.status == 1506){

										alert('注册失败,验证码错误');
										$('#codeimage').attr('src',"{{url('/makecode')}}?"+Math.random());
								}
								
							},
							dataType:'json'
						});
			     	 });
					
					</script>

				</div>
			</div>

		</div>
		</div>

		<div class="footer ">
			<div class="footer-hd ">
				<p>
					<a href="javascript:; ">恒望科技</a>
					<b>|</b>
					<a href="javascript:; ">商城首页</a>
					<b>|</b>
					<a href="javascript:; ">支付宝</a>
					<b>|</b>
					<a href="javascript:; ">物流</a>
				</p>
			</div>
			<div class="footer-bd ">
				<p>
					<a href="javascript:; ">关于恒望</a>
					<a href="javascript:; ">合作伙伴</a>
					<a href="javascript:; ">联系我们</a>
					<a href="javascript:; ">网站地图</a>
					<em>© 2015-2025 Hengwang.com 版权所有. elgots@163.com</em>
				</p>
			</div>
		</div>
	</body>

</html>